﻿namespace Sidvall.AuthorizationManager.UI.Entities
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
    public sealed partial class AuthorizationScopeResourceActionClaim : global::Sidvall.AuthorizationManager.UI.Entities.Core.BusinessBase, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim
    {
        #region Business Members

        #region AuthorizationScopeResourceActionClaimId

        private System.Nullable<long> _AuthorizationScopeResourceActionClaimId = null;
        partial void OnBeforeAuthorizationScopeResourceActionClaimIdPropertyGet(Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData);
        partial void OnBeforeAuthorizationScopeResourceActionClaimIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData);
        partial void OnAfterAuthorizationScopeResourceActionClaimIdPropertyChanged();
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        public System.Nullable<long> AuthorizationScopeResourceActionClaimId
        {
            get
            {
                Sidvall.Business.PropertyEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyEventData<System.Nullable<long>>(_AuthorizationScopeResourceActionClaimId);
                OnBeforeAuthorizationScopeResourceActionClaimIdPropertyGet(eventData);
                return eventData.Value;
            }
            internal set
            {
                Sidvall.Business.PropertyChangeEventData<System.Nullable<long>> eventData = new Sidvall.Business.PropertyChangeEventData<System.Nullable<long>>(value, _AuthorizationScopeResourceActionClaimId);
                OnBeforeAuthorizationScopeResourceActionClaimIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("AuthorizationScopeResourceActionClaimId", eventData.Value, true, true, true);
                    OnAfterAuthorizationScopeResourceActionClaimIdPropertyChanged();
                }
            }
        }

        #endregion
        #region AuthorizationScopeResourceActionId

        private long _AuthorizationScopeResourceActionId = 0L;
        partial void OnBeforeAuthorizationScopeResourceActionIdPropertyGet(Sidvall.Business.PropertyEventData<long> eventData);
        partial void OnBeforeAuthorizationScopeResourceActionIdPropertyChanged(Sidvall.Business.PropertyChangeEventData<long> eventData);
        partial void OnAfterAuthorizationScopeResourceActionIdPropertyChanged();
        public long AuthorizationScopeResourceActionId
        {
            get
            {
                Sidvall.Business.PropertyEventData<long> eventData = new Sidvall.Business.PropertyEventData<long>(_AuthorizationScopeResourceActionId);
                OnBeforeAuthorizationScopeResourceActionIdPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<long> eventData = new Sidvall.Business.PropertyChangeEventData<long>(value, _AuthorizationScopeResourceActionId);
                OnBeforeAuthorizationScopeResourceActionIdPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("AuthorizationScopeResourceActionId", eventData.Value, true, true, true);
                    OnAfterAuthorizationScopeResourceActionIdPropertyChanged();
                }
            }
        }

        #endregion
        #region ClaimType

        private string _ClaimType = string.Empty;
        partial void OnBeforeClaimTypePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeClaimTypePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterClaimTypePropertyChanged();
        public string ClaimType
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_ClaimType);
                OnBeforeClaimTypePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _ClaimType);
                OnBeforeClaimTypePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ClaimType", eventData.Value, true, true, true);
                    OnAfterClaimTypePropertyChanged();
                }
            }
        }

        #endregion
        #region ComparisonOperator

        private global::Sidvall.Data.ComparisonOperator _ComparisonOperator = global::Sidvall.Data.ComparisonOperator.Equal;
        partial void OnBeforeComparisonOperatorPropertyGet(Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnBeforeComparisonOperatorPropertyChanged(Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData);
        partial void OnAfterComparisonOperatorPropertyChanged();
        public global::Sidvall.Data.ComparisonOperator ComparisonOperator
        {
            get
            {
                Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyEventData<global::Sidvall.Data.ComparisonOperator>(_ComparisonOperator);
                OnBeforeComparisonOperatorPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator> eventData = new Sidvall.Business.PropertyChangeEventData<global::Sidvall.Data.ComparisonOperator>(value, _ComparisonOperator);
                OnBeforeComparisonOperatorPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("ComparisonOperator", eventData.Value, true, true, true);
                    OnAfterComparisonOperatorPropertyChanged();
                }
            }
        }

        #endregion
        #region IsEnabled

        private bool _IsEnabled = false;
        partial void OnBeforeIsEnabledPropertyGet(Sidvall.Business.PropertyEventData<bool> eventData);
        partial void OnBeforeIsEnabledPropertyChanged(Sidvall.Business.PropertyChangeEventData<bool> eventData);
        partial void OnAfterIsEnabledPropertyChanged();
        public bool IsEnabled
        {
            get
            {
                Sidvall.Business.PropertyEventData<bool> eventData = new Sidvall.Business.PropertyEventData<bool>(_IsEnabled);
                OnBeforeIsEnabledPropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<bool> eventData = new Sidvall.Business.PropertyChangeEventData<bool>(value, _IsEnabled);
                OnBeforeIsEnabledPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("IsEnabled", eventData.Value, true, true, true);
                    OnAfterIsEnabledPropertyChanged();
                }
            }
        }

        #endregion
        #region Value

        private string _Value = string.Empty;
        partial void OnBeforeValuePropertyGet(Sidvall.Business.PropertyEventData<string> eventData);
        partial void OnBeforeValuePropertyChanged(Sidvall.Business.PropertyChangeEventData<string> eventData);
        partial void OnAfterValuePropertyChanged();
        public string Value
        {
            get
            {
                Sidvall.Business.PropertyEventData<string> eventData = new Sidvall.Business.PropertyEventData<string>(_Value);
                OnBeforeValuePropertyGet(eventData);
                return eventData.Value;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<string> eventData = new Sidvall.Business.PropertyChangeEventData<string>(value, _Value);
                OnBeforeValuePropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("Value", eventData.Value, true, true, true);
                    OnAfterValuePropertyChanged();
                }
            }
        }

        #endregion
        #region AuthorizationScopeResourceAction

        private AuthorizationScopeResourceAction _AuthorizationScopeResourceAction;
        partial void OnBeforeAuthorizationScopeResourceActionPropertyChanged(Sidvall.Business.PropertyChangeEventData<AuthorizationScopeResourceAction> eventData);
        partial void OnAfterAuthorizationScopeResourceActionPropertyChanged();
        public AuthorizationScopeResourceAction AuthorizationScopeResourceAction
        {
            get
            {
                return _AuthorizationScopeResourceAction;
            }
            set
            {
                Sidvall.Business.PropertyChangeEventData<AuthorizationScopeResourceAction> eventData = new Sidvall.Business.PropertyChangeEventData<AuthorizationScopeResourceAction>(value, _AuthorizationScopeResourceAction);
                OnBeforeAuthorizationScopeResourceActionPropertyChanged(eventData);
                if (!eventData.Cancel)
                {
                    LoadInstanceField("AuthorizationScopeResourceAction", eventData.Value, true, true, false);
                    OnAfterAuthorizationScopeResourceActionPropertyChanged();
                }
            }
        }

        #endregion
        #region DataRowContextStorageKey

        protected override string DataRowContextStorageKey
        {
            get
            {
                return global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.GetKey(this);
            }
        }

        #endregion
        #region DataRowIsValid

        public override bool DataRowIsValid(Sidvall.Data.BusinessRuleFilter filter)
        {
            return global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.DataRowIsValid(this, filter);
        }

        #endregion
        #region DataRowStateIsDirty

        public override bool DataRowStateIsDirty
        {
            get
            {
                return global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.DataRowStateIsDirty(this);
            }
        }

        #endregion

        #region LoadAuthorizationScopeResourceActionAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceAction> LoadAuthorizationScopeResourceActionAsync()
        {
            return await LoadAuthorizationScopeResourceActionAsync(false, true, null, null, null);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceAction> LoadAuthorizationScopeResourceActionAsync(bool refresh, bool raisePropertyChanged, global::Sidvall.Data.FetchCriteria<global::Sidvall.AuthorizationManager.Data.Fields.AuthorizationScopeResourceActionField, global::Sidvall.AuthorizationManager.Data.Relations.AuthorizationScopeResourceActionRelation> criteria, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionClaimManager.LoadAuthorizationScopeResourceActionAsync(this, refresh, raisePropertyChanged, criteria, strategyContext, objectParameters);

            return this.AuthorizationScopeResourceAction;
        }
        public AuthorizationScopeResourceAction LoadAuthorizationScopeResourceAction(AuthorizationScopeResourceAction item)
        {
            LoadInstanceField("AuthorizationScopeResourceAction", item, true, true, false);
            return item;
        }

        #endregion
        #region LoadInstanceField

        public void LoadInstanceField(string fieldName, object value, bool cascade, bool raisePropertyChanged, bool updateState)
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.LoadInstanceField(this, fieldName, value, cascade, raisePropertyChanged, updateState);
        }

        #endregion
        #region AcceptChanges

        public void AcceptChanges()
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.AcceptChanges(this);
        }

        #endregion
        #region Clone

        public AuthorizationScopeResourceActionClaim Clone()
        {
            var copySettings = Sidvall.Data.CopySettings.Clone();
            return Copy(copySettings);
        }

        #endregion
        #region Copy

        public AuthorizationScopeResourceActionClaim Copy()
        {
            return Copy(null);
        }
        public AuthorizationScopeResourceActionClaim Copy(Sidvall.Data.CopySettings copySettings)
        {
            if (copySettings == null)
                copySettings = new Sidvall.Data.CopySettings();
            if (!Sidvall.Data.DataRowContextManager.IsValid(this, copySettings.RowFilter))
                return null;
            var item = new AuthorizationScopeResourceActionClaim();
            Import(item, this, copySettings);
            return item;
        }

        #endregion
        #region Import

        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim item)
        {
            Import(item, null);
        }
        public void Import(global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim item, Sidvall.Data.CopySettings copySettings)
        {
            Import(this, item, copySettings);
        }
        partial void OnAfterImport(AuthorizationScopeResourceActionClaim destination, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim source, Sidvall.Data.CopySettings copySettings);
        private void Import(AuthorizationScopeResourceActionClaim destination, global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim source, Sidvall.Data.CopySettings copySettings)
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.Import(destination, source, copySettings);
            OnAfterImport(destination, source, copySettings);
        }
        partial void OnAfterImport(AuthorizationScopeResourceActionClaim destination, AuthorizationScopeResourceActionClaim source, Sidvall.Data.CopySettings copySettings);
        private void Import(AuthorizationScopeResourceActionClaim destination, AuthorizationScopeResourceActionClaim source, Sidvall.Data.CopySettings copySettings)
        {
            Import(destination, source as global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim, copySettings);
            OnAfterImport(destination, source, copySettings);
        }

        #endregion
        #region SaveItemAsync

        public async System.Threading.Tasks.Task<AuthorizationScopeResourceActionClaim> SaveItemAsync()
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionClaimManager.SaveItemAsync(this);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceActionClaim> SaveItemAsync(Sidvall.Data.SaveMode mode)
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionClaimManager.SaveItemAsync(this, mode);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceActionClaim> SaveItemAsync(Sidvall.Data.SaveSettings settings)
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionClaimManager.SaveItemAsync(this, settings);
        }
        public async System.Threading.Tasks.Task<AuthorizationScopeResourceActionClaim> SaveItemAsync(Sidvall.Data.SaveSettings settings, string strategyContext, global::Sidvall.Data.ObjectParameterCollection objectParameters)
        {
            return await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.DataPortal.AuthorizationScopeResourceActionClaimManager.SaveItemAsync(this, settings, strategyContext, objectParameters);
        }

        #endregion
        #region ValidateAsync

        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync()
        {
            return await ValidateAsync((Sidvall.Data.ValidationSettings)null);
        }
        public async System.Threading.Tasks.Task<Sidvall.Data.BusinessRuleCollection> ValidateAsync(Sidvall.Data.ValidationSettings settings)
        {
            var context = new Sidvall.Business.ValidationContext(settings);
            await global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.ValidateAsync(this, context);
            await ValidateAsync(context);
            return context.AllBusinessRules;
        }
        partial void OnAfterValidate(Sidvall.Data.BusinessRuleCollection itemBusinessRules, Sidvall.Business.ValidationContext context);
        public async System.Threading.Tasks.Task ValidateAsync(Sidvall.Business.ValidationContext context)
        {
            var itemBusinessRules = new Sidvall.Data.BusinessRuleCollection();
            OnAfterValidate(itemBusinessRules, context);
            await context.TaskContext.DoTaskAsync();
            context.AllBusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
            var businessRulesProvider = this as Sidvall.Data.IBusinessRulesProvider;
            if (businessRulesProvider != null)
                businessRulesProvider.BusinessRules.AddRange(context.Settings.IncludeNotBrokenRules, itemBusinessRules);
        }

        #endregion
        #region Initialize

        public void Initialize()
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.Initialize(this);
        }
        public void Initialize(Sidvall.Data.InitializeSettings settings)
        {
            global::Sidvall.AuthorizationManager.UI.SystemContext.Current.EntityFacade.AuthorizationScopeResourceActionClaimManager.Initialize(this, settings);
        }

        #endregion
        
        #region IAuthorizationScopeResourceActionClaim Members

        System.Nullable<long> global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.AuthorizationScopeResourceActionClaimId
        {
            get
            {
                return this._AuthorizationScopeResourceActionClaimId;
            }
            set
            {
                this._AuthorizationScopeResourceActionClaimId = value;
            }
        }
        long global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.AuthorizationScopeResourceActionId
        {
            get
            {
                return this._AuthorizationScopeResourceActionId;
            }
            set
            {
                this._AuthorizationScopeResourceActionId = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.ClaimType
        {
            get
            {
                return this._ClaimType;
            }
            set
            {
                this._ClaimType = value;
            }
        }
        global::Sidvall.Data.ComparisonOperator global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.ComparisonOperator
        {
            get
            {
                return this._ComparisonOperator;
            }
            set
            {
                this._ComparisonOperator = value;
            }
        }
        bool global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.IsEnabled
        {
            get
            {
                return this._IsEnabled;
            }
            set
            {
                this._IsEnabled = value;
            }
        }
        string global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.Value
        {
            get
            {
                return this._Value;
            }
            set
            {
                this._Value = value;
            }
        }
        global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceAction global::Sidvall.AuthorizationManager.Data.IAuthorizationScopeResourceActionClaim.AuthorizationScopeResourceAction
        {
            get
            {
                return this._AuthorizationScopeResourceAction;
            }
            set
            {
                UpdateChildProperty(this._AuthorizationScopeResourceAction, value);
                this._AuthorizationScopeResourceAction = value as AuthorizationScopeResourceAction;
            }
        }

        #endregion

        #endregion
        #region Constructors

        public AuthorizationScopeResourceActionClaim()
        {
        }

        public AuthorizationScopeResourceActionClaim(Sidvall.Data.DataRowState? dataRowState)
            : base(dataRowState)
        {
        }

        #endregion
    }
}